package com.example.travelservlet.collectionEntertainment.service;

import com.example.travelservlet.collectionEntertainment.repository.CollectionEntertainmentRepository;
import com.example.travelservlet.entity.CollectionEntertainment;
import com.example.travelservlet.entity.EntertainmentPlan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
/**
 * @author 30697
 */
@Service
public class CollectionEntertainmentServiceImpl implements CollectionEntertainmentService{
    @Autowired
    private CollectionEntertainmentRepository collectionEntertainmentRepository;

    @Override
    public List<String> findEntertainmentIdsByCollectionId(String collectionId) {
        List<String> entertainmentIds = new ArrayList<>();
        List<CollectionEntertainment> collectionEntertainments = collectionEntertainmentRepository.findEntertainmentsByCollectionId(collectionId);
        for (CollectionEntertainment collectionEntertainment : collectionEntertainments) {
            entertainmentIds.add(collectionEntertainment.getEntertainmentId());
        }
        return entertainmentIds;
    }

    @Override
    public CollectionEntertainment createCollectionEntertainment(CollectionEntertainment collectionEntertainment) {
        return collectionEntertainmentRepository.save(collectionEntertainment);
    }

    @Override
    public void deleteCollectionEntertainmentByCollectionIdAndEntertainmentId(String collectionId, String entertainmentId) {
        collectionEntertainmentRepository.deleteCollectionEntertainmentByCollectionIdAndEntertainmentId(collectionId,entertainmentId);
    }

}
